"""
 Pandas数据分析实战
 第1部分 Pandas 核心基础
 第4章 DataFrame 对象
"""
import numpy as np
import pandas as pd
import datetime as dt


def create_dataframe_by_dict():
    city_data = {
        'City': ["New York City", "Paris", "Barcelona", "Rome"],
        "Country": ["United States", "France", "Spain", "Italy"],
        "Population": [860000, 2141000, 5515000, 2873000]
    }
    return pd.DataFrame(city_data)


def create_ndarray():
    return np.random.randint(1, 101, [3, 5])


def create_dateframe_by_ndarray():
    random_data = create_ndarray()
    print(random_data)
    return pd.DataFrame(random_data)


def create_dataframe_index():
    random_data = np.random.randint(1, 101, [3, 5])
    row_labels = ["Morning", "Afternoon", 'Evening']
    column_labels = ("Monday", "TuesDay", "Wednesday", "TuesDay", "Friday")
    temperatures = pd.DataFrame(
        data=random_data, index=row_labels, columns=column_labels
    )
    return temperatures


def read_csv():
    date_parser = lambda x: pd.to_datetime(x, format='M/D/Y')
    # nba = pd.read_csv("./file/chapter_04/nba.csv", parse_dates=["Birthday"], date_parser=date_parser)
    nba = pd.read_csv("./file/chapter_04/nba.csv", parse_dates=["Birthday"])
    return nba


if __name__ == '__main__':
    # citys = create_dataframe_by_dict()
    # print(citys.T)
    # print(citys.transpose())
    # print(create_dateframe_by_ndarray())
    nba = read_csv()
    # print(nba.dtypes)
    # print(nba.dtypes.value_counts())
    # print(nba.index)
    print(nba.columns)